<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="UTF-8">
		<title>公众号管理</title>
		<link rel="stylesheet" href="/dvmini/res/plugins/layui/css/layui.css">
		<link rel="stylesheet" href="/dvmini/res/css/Layuiglobal.css">
		<link rel="stylesheet" href="/dvmini/res/plugins/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="http://at.alicdn.com/t/font_191348_aee57zbh6jyk3xr.css">
		<link rel="stylesheet" href="/dvmini/res/css/basic.css">	
	</head>
<body>
	<div class="layui-container" style="width: 100%;">
		<ul class="publicbox">
			<!-- <li class="publicbos">
				<span style="background:url(/dvmini/res/images/moren.jpg) no-repeat center;-webkit-background-size:contain;background-size:contain;"></span>
				<p>微会互动</p>
			</li>  -->
		</ul>
		<div style="margin-left:20px;">
			<a type="button" class="layui-btn" id="add" href="${url}" target="_blank">添加公众号</a>
		</div>
		<div>
			
		</div>
		<div>
			<br/><br/>
			<input id="mpOpenid" style="widht:150px" title="测试者的公众号openid" value="oXqmKwSoVLT31zRncvr9Q5pWiLFI"/>
			<br/><br/>
			<a type="button" class="layui-btn"  id="test" href="javascript:;" target="_blank" >测试发送模板消息</a>
		</div>
			
	</div>
	
	<script src='/dvmini/res/js/jquery.min.js'></script>
	<script type="text/javascript" src="/dvmini/res/js/jquery.qqFace.js"></script>
	<script src="/dvmini/res/plugins/layui/layui.js" charset="utf-8"></script>
	<script src="/dvmini/res/js/me.js"></script>
	<script>
	layui.use(['form', 'element', 'laydate', 'layer', 'laypage'], function(){	
		var template_id_short="OPENTM412547082"; //客户咨询通知的模板短ID。
		 
		/*
		$.post("/dvmini/pcwx/getTemplate",{template_id_short:template_id_short},function(data){
			if(data.msg!="") $("#info").html("模板消息已添加,TempletID=" + data.msg);			
		})
		*/
		
		 $("#addTemplate").click(function(){
				$.post("/dvmini/pcwx/addTemplate",{template_id_short:template_id_short},function(data){
					console.log(data);
					if (data.msg.indexOf("error")>-1){						
						alert("添加失败,原因：" + data.msg);					
					}
					else
					{
						$("#info").html("模板消息已添加,TempletID=" + data.msg);	
						alert("添加成功!");
					}
				})
		})
		
		$("#test").click(function(){
			var openid = $("#mpOpenid").val();
			$.post("/dvmini/pcwx/testSendTemplate",{mpOpenid:openid,rand:new Date().toString()},function(data){
				alert(data);
			})
		})
		
	
		//获取公众号
		 $.post("/dvmini/pcwx/getwx",function(data){
			console.log(data)
			if(data.code==0){
				var str ='<li class="publicbos">'
					+'<span style="background:url('+ data.data.headimg +') no-repeat center;-webkit-background-size:contain;background-size:contain;"></span>'
					+'<p>'+ data.data.wxname +'</p>'
				+'</li>';
				$(".publicbox").html(str);
			}else{
				top.layer.msg(data.msg)
			}
			
			
		}) 
		
	})

	</script>
</body>
</html>